const express = require('express')
const {frontIp,backPort} = require('./config.json')
const app = express()
const http = require('http')
const server = http.createServer(app)
const {Server} = require('socket.io')
const io = new Server(server,{
  cors:{
    origin: frontIp
  }
});


io.on('connection',socket=>{
  socket.on('changePaint',msg=>{
    socket.broadcast.emit('paint',{data:msg})
    socket.broadcast.emit('painter',{data:msg.painter})
  })

})
server.listen(backPort,()=>{
  console.log('start');
})